package com.yoomiito.app.adapter;

import android.text.Html;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yoomiito.app.R;
import com.yoomiito.app.model.bean.GoodsDetail;
import com.yoomiito.app.model.bean.GoodsList;
import com.yoomiito.app.model.order.OrderDetailGoods;
import com.yoomiito.app.ui.order.detail.OrderInfoJiaMaiCodeAdapter;
import com.yoomiito.app.ui.order.detail.WuLIuActivity;
import com.yoomiito.app.utils.AllCode;
import com.yoomiito.app.utils.AllUtils;
import com.yoomiito.app.utils.DensityUtil;
import com.yoomiito.app.utils.ImageLoader;
import com.yoomiito.app.utils.ResUtil;
import com.yoomiito.app.utils.SpannableUtils;
import com.yoomiito.app.utils.YMToast;
import com.yoomiito.app.widget.NumControlView;
import com.yoomiito.app.widget.OnNumberChangeListener;
import com.yoomiito.app.widget.RoundImageView;
import com.yoomiito.app.widget.SpacingDecoration;

import java.util.List;

import chihane.jdaddressselector.AddressProvider;
import chihane.jdaddressselector.model.Province;

public class PickGoodsAdapter extends BaseQuickAdapter<GoodsDetail, BaseViewHolder> {

    OnClick onClick;

    public PickGoodsAdapter() {
        super(R.layout.item_pick_goods);
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodsDetail item) {
        ImageView roundImageView = helper.getView(R.id.item_order_goods_iv);
        ImageLoader.getInstance().into(roundImageView.getContext(), item.banner, roundImageView);

        helper.setText(R.id.item_order_goods_title, item.getTitle());
        helper.setText(R.id.item_order_goods_price, "¥" + item.price);
        helper.setText(R.id.item_order_goods_tip, Html.fromHtml(item.msg));

        NumControlView numControlView = helper.getView(R.id.num_control_view);
        numControlView.setStep(item.step);
        numControlView.setMax(item.goodsNum);
        numControlView.setMin(0);
        numControlView.setListener(new OnNumberChangeListener() {
            @Override
            public void numberChange(int num) {
                item.setNum = num;
            }
        });
        if (item.goodsNum == 0) {
            numControlView.setNoClick(false);
        } else {
            numControlView.setNoClick(true);
        }
        numControlView.setText("提货数量不能小与0","提货数量不能大于");

    }


    public void setOnGoods(OnClick onClick) {
        this.onClick = onClick;
    }

    public interface OnClick {
        void onGetGood(String goods);
    }

}
